<?php
namespace app\admin\model;
use think\Model;
use traits\model\SoftDelete;

class RecoveryCategory extends Model
{
    use SoftDelete;
    // 表名
    protected $name = 'recovery_category';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = 'deletetime';
    // 追加属性
    protected $append = [
    ];
    /**
     * 获取子集分类查询条件
     * @return \think\model\relation\HasMany
     */
    public function children()
    {
        return $this->hasMany(self::class, 'pid', 'id')->order('id ASC');
    }
    /**
     * 获取父级分类查询条件
     * @return \think\model\relation\belongsTo
     */
    public function parent()
    {
        return $this->belongsTo(self::class, 'pid', 'id')->setEagerlyType(0);
    }
}
